from django.db import models


# Create your models here.
class User(models.Model):
    id = models.AutoField(primary_key=True)
    username = models.CharField(null=False, max_length=32)
    password = models.CharField(null=False, max_length=32)


class Publisher(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(null=False, max_length=32)


class Book(models.Model):
    name = models.CharField(max_length=32)
    publisher = models.ForeignKey(to=Publisher, on_delete=models.CASCADE)


class Author(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    books = models.ManyToManyField(to=Book, related_name="authors")
